
import config from '@/config/config.js';
import axios from "axios";

const upkeepTypeRequest = {
    loadAllUpkeepType(upkeepTypeSearch,pageNum,limit,callback){
        let url = config.deviceBaseUrl + "/upkeepType/list?pageNum=" + pageNum + "&limit=" + limit;
        if (upkeepTypeSearch.upkeepTypeName){
            url += "&upkeepTypeName=" + upkeepTypeSearch.upkeepTypeName
        }
        if (upkeepTypeSearch.upKeepTypeId){
            url += "&upkeepTypeId=" + upkeepTypeSearch.upKeepTypeId
        }
        if (upkeepTypeSearch.upkeepTypeType){
            url += "&upkeepTypeType=" + upkeepTypeSearch.upkeepTypeType
        }
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data)
        })
    },
    loadSearchPojo(upkeepTypeId,callback){
        let url = config.deviceBaseUrl + "/upkeepType/getUpdate?upkeepTypeId=" + upkeepTypeId;
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data)
        })
    },
    insertUpkeepType(upkeepType,callback){
        let url = config.deviceBaseUrl + "/upkeepType/insert"
        axios.post(url,upkeepType,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data)
        })
    },
    updateUpkeepType(upkeepType,callback){
        let url = config.deviceBaseUrl + "/upkeepType/update"
        axios.put(url,upkeepType,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data)
        })
    },
    deleteUpkeepType(upkeepTypeId,callback){
        let url = config.deviceBaseUrl + "/upkeepType/delete?upkeepTypeId=" + upkeepTypeId;
        axios.delete(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data)
        })
    }
}
export default upkeepTypeRequest;